<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="utf-8"/>
    <title>test</title>
    <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="js/sso.js"></script>
</head>
<body>
<div>
    <p>用户名：<span id="userName"></span>【<span id="nickName"></span>】</p>
    <p>所属企业：[<span id="tenantName"></span>]</p>
    <p>应用id：<span id="clientId"></span></p>
    <p>token：<span id="accessToken"></span></p>
    <p><input type="button" value="登出" onclick="logout()"/></p>
	<p><input type="button" value="登出2" onclick="logout2()"/></p>
</div>
<script>
    window.onload = function() {
        let accessToken = sessionStorage.getItem('access_token');
        if (accessToken) {//已登录
            //let userName = sessionStorage.getItem('userName');
            //let nickName = sessionStorage.getItem("nickName");
            //$('#accessToken').html(accessToken);
            //$('#userName').html(userName);
			//$('#nickName').html(nickName);
            //$('#tenantName').html(tenantName);
            //$('#clientId').html(clientId);
            let result_data = sessionStorage.getItem('result_data');
            console.log(result_data);
            $('#accessToken').html(accessToken);
            $('#userName').html(result_data);
        } else {//未登录
            let state = getState();
            sessionStorage.setItem("visitUri", window.location.href);
            sessionStorage.setItem("state", state);
            window.location = getAuthorizeUri(state);
        }
    };

    function logout() {
        let accessToken = sessionStorage.getItem('access_token');
        sessionStorage.removeItem('access_token');
		sessionStorage.removeItem('userName');
        sessionStorage.removeItem('nickName');
        sessionStorage.removeItem("tenantName");
        window.location = getLogoutUri(accessToken);
    }
	
	function logout2() {
		let accessToken = sessionStorage.getItem('access_token');
        sessionStorage.removeItem('access_token');
		sessionStorage.removeItem('userName');
        sessionStorage.removeItem('nickName');
        sessionStorage.removeItem("tenantName");
		getLogoutUriAjax(accessToken);
	}
</script>
</body>
</html>
